package atencion_de_emergencia.dao;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;

import utilitarios.MiConexion;
import atencion_de_emergencia.bean.AnimalMordedorDTO;
import atencion_de_emergencia.interfaces.AnimalMordedorDAO;

public class MySqlAnimalMordedorDAO implements AnimalMordedorDAO{

	@Override
	public String registrarAM(AnimalMordedorDTO objAM)  throws SQLException{
		Connection conexion = MiConexion.obtenerConexion();
		CallableStatement call = null;
		String strCodigo = "";
			
			call = conexion.prepareCall("{call usp_registrarAM(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
			call.registerOutParameter(17, java.sql.Types.CHAR);
					
			call.setString(1, objAM.getStrNom_Ani());
			call.setString(2, objAM.getStrNom_Propi());
			call.setString(3, objAM.getStrDomi_Propi());
			call.setString(4, objAM.getStrRef_Domi_Propi());
			java.sql.Date fec_nac = new java.sql.Date(objAM.getStrFecnac_Ani().getTime());
			call.setDate(5,fec_nac );		
			call.setString(6, objAM.getStrSexo_Ani() );
			call.setString(7, objAM.getStrTam_Ani() );
			
			call.setString(8,objAM.getStrCod_Especi());
			call.setString(9,objAM.getStrCod_Raza());
			call.setString(10,objAM.getStrCod_Color());
			call.setString(11,objAM.getStrCod_Depa());
			call.setString(12,objAM.getStrCod_Prov());
			call.setString(13,objAM.getStrCod_Distri());
			
			call.setString(14, "u0002");
			call.setString(15, "insert");
			call.setString(16, "oae01");
			call.executeUpdate();
			strCodigo = call.getString(17);
			System.out.println(strCodigo);
			call.close();
			conexion.close();
	
		return strCodigo;
		
	}

}
